package com.atlassian.jira.resource;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "group")
public class DefaultGroup implements Group{

	private String name;
	private Collection<String> userNames;

	public DefaultGroup() {
	}
	
	public DefaultGroup(com.opensymphony.user.Group group){		
		this.userNames = new ArrayList<String>();
		Collection<?> users = group.getUsers();		
		if(users == null){ users = new ArrayList<com.opensymphony.user.User>(); }
		
		this.name = group.getName();
		for(Iterator<?> i = users.iterator(); i.hasNext();){
			com.opensymphony.user.User user = (com.opensymphony.user.User) i.next();
			this.userNames.add(user.getName());
		}		
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Collection<String> getUserNames() {
		return userNames;
	}

	public void setUserNames(Collection<String> userNames) {
		this.userNames = userNames;
	}

}
